//
//  VipViewController.m
//  ebook
//
//  Created by 吴超飞 on 2016/12/30.
//  Copyright © 2016年 Moton. All rights reserved.
//

#import "VipViewController.h"
#import "VipPayView.h"

@interface VipViewController ()

@end

@implementation VipViewController

- (void)viewDidLoad {
   
    [super viewDidLoad];
    
    self.title = @"包月VIP";
    [self createBackItem];
    
    _payBtn.layer.cornerRadius = 5;
    _payBtn.backgroundColor = MTConfigColor(@"MTNavigationBar_background_Color");
    _payBtn.tintColor = MTConfigColor(@"MTNavigationBar_title_Color");

    NSInteger vipTime = [[NSUserDefaults standardUserDefaults]integerForKey:kVipOverTime];
    if(vipTime){
        _imgBtn.selected = YES;
        _infoLabel.text = @"包月VIP已开通";
        [_payBtn setTitle:@"续费" forState:UIControlStateNormal];
        _timeLabel.hidden = NO;
        _timeLabel.text = [NSString stringWithFormat:@"有效期至%@",[self timestampSwitchDate:vipTime]];
    }else{
        _imgBtn.selected = NO;
        _infoLabel.text = @"包月VIP未开通";
        [_payBtn setTitle:@"开通包月VIP" forState:UIControlStateNormal];
        _timeLabel.hidden = YES;
    }
    
    [_imgBtn setNeedsDisplay];
    [_infoLabel setNeedsDisplay];
    [_payBtn setNeedsDisplay];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)payBtnClick:(id)sender {
    NSInteger vipTime = [[NSUserDefaults standardUserDefaults]integerForKey:kVipOverTime];
    [VipPayView showIsRenew:vipTime];
}

@end
